package com.lingCheng.avg.controller;

import com.lingCheng.avg.common.BackCode;
import com.lingCheng.avg.controller.fo.MyRequestData;
import com.lingCheng.avg.entity.AgvErrorInfo;
import com.lingCheng.avg.entity.TaskChainPo;
import com.lingCheng.avg.entity.TaskPo;
import com.lingCheng.avg.service.AgvService;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.weaver.bcel.BcelAccessForInlineMunger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@Slf4j
public class AgvController {
    @Autowired
    private AgvService agvService;

    @PostMapping("/push/taskInfo")
    public BackCode BackRW(@RequestBody MyRequestData myRequestData){
        TaskPo taskPo=myRequestData.getTaskPo();
        TaskChainPo taskChainPo=myRequestData.getTaskChainPo();
        System.out.println(taskChainPo+"====="+taskPo);
        log.info("主任务:{},子任务{}",taskChainPo,taskPo);
        agvService.findBack(taskChainPo);
        return BackCode.success();
    }

    @PostMapping("/push/errorInfo")
    public Map<String,Object> getErrorInfo(@RequestBody AgvErrorInfo errorInfo){

        agvService.getAgvErrorInfo(errorInfo);

        Map<String,Object> response = new HashMap<>();
        response.put("errMsg","操作成功");
        response.put("errCode","0");
        response.put("state",true);
        return response;
    }

}
